package com.hjy.controller;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "Get", value = "/get")
public class Get extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html; charset=UTF-8");
        ServletContext context = request.getServletContext();
        String username = (String) context.getAttribute("username");
        PrintWriter writer = response.getWriter();
        writer.write("名字:"+username);
//        response.sendRedirect("/image");
        response.setHeader("Location","/image");
        response.setStatus(302);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
